﻿using System;
using System.Linq;
using System.Linq.Expressions;
namespace DDD.Domain
{
    public interface IBaseRepository<T> where T:class
    {
        T GetSingle(Expression<Func<T, bool>> exp = null);

        IQueryable<T> Find(Expression<Func<T, bool>> exp = null);


        IQueryable<T> Find(int pageindex = 1, int pagesize = 10,
            Expression<Func<T, bool>> exp = null);

        int GetCount(Expression<Func<T, bool>> exp = null);

        void Add(T entity);

        /// <summary>
        /// 更新一个实体的所有属性
        /// </summary>
        void Update(T entity);

        void Delete(T entity);

        /// <summary>
        /// 批量更新
        /// </summary>
        void Update(Expression<Func<T, bool>> exp, T entity);

        /// <summary>
        /// 批量删除
        /// </summary>
        void Delete(Expression<Func<T, bool>> exp);

        void Save();
    }
}